package com.cy.factory;

import com.cy.service.RemoteProviderService;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

/**
 * 基于此对象处理RemoteProviderService接口调用时出现的异常问题
 */
@Component
public class RemoteFallbackFactory implements FallbackFactory<RemoteProviderService> {
    /**
     * 此方法在RemoteProviderService接口调用出现异常后执行
     * @param throwable 用于接收异常
     * @return
     */
    @Override
    public RemoteProviderService create(Throwable throwable) {
        return new RemoteProviderService() {
            @Override
            public String echoMsg(String msg) {
                return "call excpetion : msg is " + throwable.getMessage();
            }
        };
    }
}
